package com.funwithcode.res;

/* 
 * Copyright (c) 2014 Jaco Malan
 * 
 * Permission is hereby granted, free of charge, to anybody obtaining a copy of this
 * software to use, modify, publish or republish under the terms of
 * the GNU General Public License v3.0
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, NOT EVEN
 * THE GUARANTEE OF MERCHANTIBILITY OR FITNESS FOR A SPECIFIC PURPOSE.
 * THE DEVELOPERS WILL TAKE NO RESPONSIBILITY FOR ANY DAMAGES TO ANYONE
 * AND/OR DEVICE.
 * 
 * A copy of the GNU General Public License v3.0 should've been supplied
 * prior to downloading a copy of this software.
 * If not you can obtain a copy here: http://www.gnu.org/licenses/gpl.html 
 * 
 */

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * 
 * @author Jaco Malan
 *
 */

public class ResActivity extends ActionBarActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_res);
        
        final Button button7 = (Button) findViewById(R.id.button7);
        button7.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String command[]={"ls", "/storage/sdcard0/Downloads"};
				Shell shell = new Shell();
				String text = shell.sendShellCommand(command);
				setNewTextInTextView(text);
			}
		});
        
        final Button button6 = (Button) findViewById(R.id.button6);
        button6.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String command[]={"su", "-c", "ls /root"};
				Shell shell = new Shell();
				String text = shell.sendShellCommand(command);
				setNewTextInTextView(text);
			}
		});
        
        final Button button5 = (Button) findViewById(R.id.button5);
        button5.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String command[]={"ls", "/storage/sdcard0"};
				Shell shell = new Shell();
				String text = shell.sendShellCommand(command);
				setNewTextInTextView(text);
			}
		});
        
        final Button button4 = (Button) findViewById(R.id.button4);
        button4.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String text = "Contact me on, +27824511426 or jacomalan.12@gmail.com";
				displayContactDetails(text);
			}
		});
        
        final TextView textView1 = (TextView) findViewById(R.id.textView1);
        textView1.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String text = "Adam Outler(Shell.java), Jaco Malan(Main developer)";
				displayCredits(text);
			}
		});
        
        final Button button3 = (Button) findViewById(R.id.button3);
        button3.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String command[]={"ls", "/storage/extSdCard"};
				Shell shell = new Shell();
				String text = shell.sendShellCommand(command);
				setNewTextInTextView(text);
			}
		});
        
        final Button button2 = (Button) findViewById(R.id.button2);
        button2.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String command[]={"ls", "/"};
				Shell shell = new Shell();
				String text = shell.sendShellCommand(command);
				setNewTextInTextView(text);
			}
		});
        
        final Button button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String command[]={"su", "-c", "ls /data/data"};
				Shell shell = new Shell();
				String text = shell.sendShellCommand(command);
				setNewTextInTextView(text);
			}
		});
    }
    
    private void setNewTextInTextView(String text){
    	TextView text1 = new TextView(this);
    	text1.setText(text);
    	setContentView(text1);
    }
    
    public void displayCredits(String text){
    	TextView credits = new TextView(this);
    	credits.setText(text);
    	setContentView(credits);
    }
    
    public void displayContactDetails(String text){
    	TextView contact = new TextView(this);
    	contact.setText(text);
    	setContentView(contact);
    }
}


